package com.pragmaticminds.bernardo.creditos.util
{
	import mx.controls.Alert;
	import mx.controls.dataGridClasses.DataGridColumn;

	public class DataGridColumnNested extends DataGridColumn
	{
		public function DataGridColumnNested(columnName:String=null)
		{
			super(columnName);
		}
		
		override public function itemToLabel(data:Object):String
		{
	        if (dataField.indexOf(".") != -1)
	        { 
		        var fields:Array = dataField.split(".");
		        var currentData:Object = data;
		        for each(var field:String in fields)
		        	currentData = currentData[field];
		         
		        var label:String;
		        if (currentData is String)
		            label = String(currentData);
		
		        try
		        {
		            label = currentData.toString();
		        }
		        catch(e:Error)
		        {
		        	return "";
		        }
		        
	        	return label;
	        }
	        
	        return super.itemToLabel(data);
		}
		
	}
}